#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;

string pattern;

// 检查是否存在长度<=len的回文子串
bool hasPalindromeUpToLength(int len) {
    for (int l = 2; l <= len; l++) {
        for (int i = 0; i + l <= pattern.size(); i++) {
            int left = i, right = i + l - 1;
            bool isPal = true;
            while (left < right) {
                if (pattern[left] != pattern[right]) {
                    isPal = false;
                    break;
                }
                left++;
                right--;
            }
            if (isPal) return true;
        }
    }
    return false;
}

int main()
{
    cin >> pattern;
    int n = pattern.size();
    if(n < 2)
    {
        cout << -1 << endl;
        return 0;
    }
    vector<int> tmp;
    for(int i = 2 ;i <= pattern.size(); i++)
        tmp.push_back(i);
    auto it = lower_bound(tmp.begin(), tmp.end(), true, [](int len, bool value)
        {
            return !hasPalindromeUpToLength(len);
        });
    if(it == tmp.end())
    {
        cout << -1 << endl;
    }
    else
    {
        cout << *it << endl;
    }
    return 0;
}